package file;

import javax.swing.*;
import java.awt.*;
import java.net.URL;

/**
 * 点资源
 */
public class Point {
    private final int BASE_SIZE = 16;
    private int X; // 基本坐标X
    private int Y; // 基本坐标Y
    private ImageIcon icon; // 基本icon

    // 初始化
    public Point(ImageIcon imageIcon, int X, int Y) {
        this.icon = imageIcon;
        this.X = X;
        this.Y = Y;
    }

    // 点设置
    public void setPoint(int X, int Y) {
        this.X = X;
        this.Y = Y;
    }

    /**
     * 判断是否重叠
     */
    public boolean isOver(Point p){
        if(p.getX() == this.getX() && p.getY() == this.getY()){
            return true;
        }
        return false;
    }
    public boolean isOver(int X, int Y){
        if(X == this.getX() && Y == this.getY()){
            return true;
        }
        return false;
    }

    // 点的显示
    public void showPoint(Component c, Graphics g) {
        this.icon.paintIcon(c, g, X * BASE_SIZE, Y * BASE_SIZE);
    }
    // 取得
    public int getX() {
        return X;
    }
    public int getY() {
        return Y;
    }

    // 资源地址
    private static URL url_header = Point.class.getResource("/point/header.jpg");
    private static URL url_body = Point.class.getResource("/point/body.jpg");
    private static URL url_score = Point.class.getResource("/point/score.jpg");
    // 图片对象
    public static ImageIcon header = new ImageIcon(url_header);
    public static ImageIcon body = new ImageIcon(url_body);
    public static ImageIcon score = new ImageIcon(url_score);
}
